package com.afterglow.lcsrpc.server;

import io.vertx.core.Vertx;

/**
 * Description:
 * Date: 2024/12/08
 * author: lcs
 */
public class VertxHttpServer implements HttpServer{
    @Override
    public void doStart(int port) {
        //创建Vert.x实例
        Vertx vertx = Vertx.vertx();

        //创建http服务器
        io.vertx.core.http.HttpServer server = vertx.createHttpServer();

        //监听端口并处理请求
        server.requestHandler(new HttpServerHandler());

        //启动http服务器并监听指定端口
        server.listen(port,result -> {
            if (result.succeeded()){
                System.out.println("服务监听端口：" + port);
            }else {
                System.out.println("监听端口失败：" + result.cause());
            }
        });
    }
}
